Note: This tutorial assumes that you have completed the previous tutorials: Creating a Workspace for Catkin, How to Pair the PS3 Joystick with a Bluetooth Dongle, Configuring A Linux Joystick, Arduino IDE Setup. |
Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags. |
Musical Keyboard Operated by PS3 Controller
Description: In this tutorial, you will write a node (python) to control a buzzer via an Arduino using a PS3 controller. You will also write a node on the Arduino to make it play different notes when different keys on the PS3 controller are pressed, effectively making a 'musical keyboard'.Tutorial Level: INTERMEDIATE
Before starting the tutorial, please take the time to create your ROS workspace using either the catkin or rosbuild method. You will need this workspace to build your package and node later.
Setting up the PS3 Controller
First, follow the instructions at How to Pair the PS3 Joystick with a Bluetooth Dongle to connect your PS3 controller with linux. Once you see the words Connection is Activated. your controller is ready to be used as a Linux-supported joystick.
Once this is done, follow the instructions at Configuring A Linux Joystick to start running 'joy_node'. This node publishes to a topic 'joy' with the message type 'sensor_msgs/Joy'. These messages consist of the int32[] buttons array which shows '1' for buttons that are pressed and '0' for buttons which are not pressed. Do not worry too much about which numbers correspond to which buttons for now.